#include<string>
#include<iostream>
using namespace std;
int main()
{
    FILE *ad;
    char s[100];
    string str;
    string adc;
	char x;
	while(1)     
	{
	int C=0，int W=0，int S=0; 
	    cout<<"先输入wc.exe，功能，文件："<<endl;
	    cout<<"-C为字符数,-s为句子数,-w为单词数"<<endl;
		cin>>str;
		if(str!="wc.exe")cout<<"输入wc.exe"<<endl;     
		if(str=="wc.exe"){
	    cin>>s;
	    if(s[1]=='a')     //字符数 
		{
		    cin>>dz;
            if((wd=fopen((dz).c_str(),"r"))==NULL)    
		    cout<<"error"<<endl;     
		    x=fgetc(wd);      
		    while(x!=EOF)      
			{   
		        C++;      
		        x=fgetc(wd);   
			}
	        fclose(wd);     
		    cout<<"字符数为："<<C<<endl;
		}
	   
	    else if(s[1]=='s')    
		{
		    cin>>dz;
            if((wd=fopen((dz).c_str(),"r"))==NULL)    
			cout<<"error"<<endl;
            x=fgetc(wd);
		    while(x!=EOF)
			{
			    if(x=='?'||x=='！'||x=='.')    //遇见问号感叹号句号等结束标点符号时加1 
     		    S++;
			    x=fgetc(wd);
			}
		    fclose(wd);
		    cout<<"句子数为："<<S<<endl;
		} 
		else if(s[1]=='w')  //单词数 
		{   int t;
		    cin>>dz;
            if((wd=fopen((dz).c_str(),"r"))==NULL)    
            cout<<"error"<<endl;
		    x=fgetc(wd);
	        while(x!=EOF)
			{   
			    if(x<='Z'&&x>='A'||x<='z'&&x>='a')
                t=1;
		        if((x==' '||x=='?'||x=='\0'||x=='\n'||x=='.'||x=='!'||x==',')&&t==1)     //遇见间隔符号时时加1 
				{   
				    t=2;
			        W++;
				}
		        x=fgetc(wd);
			}
	        fclose(wd);
		    cout<<"单词数为："<<W<<endl;
		}
	    else
		{
		    cout<<"请输入正确的指令"<<endl;
		}
	}
	}
	return 0;
}